
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ page import="com.dts.entity.Users" %>
<%@ page import="com.dts.entity.Role" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.LinkedHashMap" %>
<%@ page import="java.util.Map" %>
<html>
<body>
<%
    Users user1 = new Users();
    user1.setUsername("1001");
    user1.setRealName("张三");
    Users user2 = new Users();
    user2.setUsername("1002");
    user2.setRealName("李四");
    List<Users> list = new ArrayList<Users>();
    list.add(user1);
    list.add(user2);
    request.setAttribute("list", list);
%>
使用 EL 表达式获取list集合中指定位置的数据：${list[0].realName}、${list[1].realName}
<hr>
<br>
<%
    Map<String, String> map = new LinkedHashMap<String, String>();
    map.put("a", "aaaa");
    map.put("b", "bbbb");
    map.put("c", "cccc");
    request.setAttribute("map", map);
%>
使用 EL 表达式获取map集合的数据${map.a} ${map["c"]}
</body>

</html>